{include file="public_iframe:head"}
<script type="text/javascript" charset="utf-8" src="__STATIC__/editor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__STATIC__/editor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="__STATIC__/editor/lang/zh-cn/zh-cn.js"></script>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>
                {switch name="type"}
                    {case value="1"}淘一商城{/case}
                    {case value="2"}天猫{/case}
                    {case value="3"}淘宝{/case}
                    {default /}
                {/switch}
            </h5>
            <div class="ibox-tools" style="margin-top: -9px;">
                <a href="javascript:history.go(-1);" class="btn btn-primary"><i class="fa fa-arrow-left"></i> 返回</a>
            </div>
        </div>

        <div class="ibox-content">
            <form action="" method="post" enctype="multipart/form-data" id="brandForm" class="form-horizontal">
                    <input type="hidden" name="id" value="{$da.id?$da.id:'';}">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">链接</label>
                        <div class="col-sm-6">
                            <input type="text" name="link" id="link" value="{$da.link?$da.link:'';}" class="form-control" placeholder="链接" >
                        </div>
                    </div>
                    <div class="form-group">
                    <div class="hr-line-dashed"></div>
                        <label class="col-sm-2 control-label">选择位置</label>
                        <select class="col-sm-6" name="type" id="type">
                            <option value="1" {if condition="isset($da.type) and $da.type=='1'"}selected = "selected"{/if}>淘一</option>
                            <option value="2" {if condition="isset($da.type) and $da.type=='2'"}selected = "selected"{/if}>淘宝天猫</option>
                        </select>
                    </div>
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <div class="col-sm-4 col-sm-offset-2">
                            <!--<button class="btn btn-primary" type="submit">提交</button>-->
                            <!--href="JavaScript:void(0);" onclick="roleSubmit();"-->
                            <a href="JavaScript:void(0);" onclick="Submit();" class="btn btn-primary" id="submit">提交</a>
                        </div>
                    </div>
                
          

            </form>
        </div>
    </div>
    <!-- End Panel Basic -->
</div>
<script>
     function Submit(){
        var formData = new FormData();
        var id = $('input[name="id"]').val();
        var link = $('input[name="link"]').val();
        
        var myselect=document.getElementById("type");
        var index = myselect.selectedIndex;
        var type = myselect.options[index].value;

        formData.append('id',id);
        formData.append('link',link);
        formData.append('type',type);
        $.ajax({
            url:"{:url('Link/doedit')}",
            type:'POST',
            data:formData,
            async:false,
            processData:false,
            contentType:false,
            success:function(result) {
                if(result.code == '0'){
                    parent.layer.alert(result.msg);
                }else{
                    parent.layer.msg(result.msg,{
                                icon:1,
                                time:1000,
                            },
                            function (index, item) {
                                /*history.go(-1);*/
                                window.location.href="{:url('Link/lists')}";
                            });
                }
            }
        });
    }
</script>
<script type="text/javascript">

    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    var ue = UE.getEditor('editor');


    function isFocus(e){
        alert(UE.getEditor('editor').isFocus());
        UE.dom.domUtils.preventDefault(e)
    }
    function setblur(e){
        UE.getEditor('editor').blur();
        UE.dom.domUtils.preventDefault(e)
    }
    function insertHtml() {
        var value = prompt('插入html代码', '');
        UE.getEditor('editor').execCommand('insertHtml', value)
    }
    function createEditor() {
        enableBtn();
        UE.getEditor('editor');
    }
</script>
<script type="text/javascript">
    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    var ues = UE.getEditor('editor_two');

    function isFocus(e){
        alert(UE.getEditor('editor_two').isFocus());
        UE.dom.domUtils.preventDefault(e)
    }
    function setblur(e){
        UE.getEditor('editor_two').blur();
        UE.dom.domUtils.preventDefault(e)
    }
    function insertHtml() {
        var value = prompt('插入html代码', '');
        UE.getEditor('editor_two').execCommand('insertHtml', value)
    }
    function createEditor() {
        enableBtn();
        UE.getEditor('editor_two');
    }
</script>
</body>

</html>